\(\int \cot ^2(e+f x) (a+b \sec ^2(e+f x)) \, dx\) [321]

   Optimal result
   Rubi [A] (verified)
   Mathematica [C] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [F]
   Maxima [A] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 21, antiderivative size = 19 \[ \int \cot ^2(e+f x) \left (a+b \sec ^2(e+f x)\right ) \, dx=-a x-\frac {(a+b) \cot (e+f x)}{f} \]

[Out]

-a*x-(a+b)*cot(f*x+e)/f

Rubi [A] (verified)

Time = 0.06 (sec) , antiderivative size = 19, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.143, Rules used = {4226, 1816, 209} \[ \int \cot ^2(e+f x) \left (a+b \sec ^2(e+f x)\right ) \, dx=-\frac {(a+b) \cot (e+f x)}{f}-a x \]

[In]

Int[Cot[e + f*x]^2*(a + b*Sec[e + f*x]^2),x]

[Out]

-(a*x) - ((a + b)*Cot[e + f*x])/f

Rule 209

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[b, 2]))*ArcTan[Rt[b, 2]*(x/Rt[a, 2])], x] /;
 FreeQ[{a, b}, x] && PosQ[a/b] && (GtQ[a, 0] || GtQ[b, 0])

Rule 1816

Int[(Pq_)*((c_.)*(x_))^(m_.)*((a_) + (b_.)*(x_)^2)^(p_.), x_Symbol] :> Int[ExpandIntegrand[(c*x)^m*Pq*(a + b*x
^2)^p, x], x] /; FreeQ[{a, b, c, m}, x] && PolyQ[Pq, x] && IGtQ[p, -2]

Rule 4226

Int[((a_) + (b_.)*sec[(e_.) + (f_.)*(x_)]^(n_))^(p_.)*((d_.)*tan[(e_.) + (f_.)*(x_)])^(m_), x_Symbol] :> With[
{ff = FreeFactors[Tan[e + f*x], x]}, Dist[ff/f, Subst[Int[(d*ff*x)^m*((a + b*(1 + ff^2*x^2)^(n/2))^p/(1 + ff^2
*x^2)), x], x, Tan[e + f*x]/ff], x]] /; FreeQ[{a, b, d, e, f, m, p}, x] && IntegerQ[n/2] && (IntegerQ[m/2] ||
EqQ[n, 2])

Rubi steps \begin{align*} \text {integral}& = \frac {\text {Subst}\left (\int \frac {a+b \left (1+x^2\right )}{x^2 \left (1+x^2\right )} \, dx,x,\tan (e+f x)\right )}{f} \\ & = \frac {\text {Subst}\left (\int \left (\frac {a+b}{x^2}-\frac {a}{1+x^2}\right ) \, dx,x,\tan (e+f x)\right )}{f} \\ & = -\frac {(a+b) \cot (e+f x)}{f}-\frac {a \text {Subst}\left (\int \frac {1}{1+x^2} \, dx,x,\tan (e+f x)\right )}{f} \\ & = -a x-\frac {(a+b) \cot (e+f x)}{f} \\ \end{align*}

Mathematica [C] (verified)

Result contains higher order function than in optimal. Order 5 vs. order 3 in optimal.

Time = 0.08 (sec) , antiderivative size = 43, normalized size of antiderivative = 2.26 \[ \int \cot ^2(e+f x) \left (a+b \sec ^2(e+f x)\right ) \, dx=-\frac {b \cot (e+f x)}{f}-\frac {a \cot (e+f x) \operatorname {Hypergeometric2F1}\left (-\frac {1}{2},1,\frac {1}{2},-\tan ^2(e+f x)\right )}{f} \]

[In]

Integrate[Cot[e + f*x]^2*(a + b*Sec[e + f*x]^2),x]

[Out]

-((b*Cot[e + f*x])/f) - (a*Cot[e + f*x]*Hypergeometric2F1[-1/2, 1, 1/2, -Tan[e + f*x]^2])/f

Maple [A] (verified)

Time = 0.57 (sec) , antiderivative size = 33, normalized size of antiderivative = 1.74

method result size
derivativedivides \(\frac {a \left (-\cot \left (f x +e \right )-f x -e \right )-b \cot \left (f x +e \right )}{f}\) \(33\)
default \(\frac {a \left (-\cot \left (f x +e \right )-f x -e \right )-b \cot \left (f x +e \right )}{f}\) \(33\)
risch \(-a x -\frac {2 i a}{f \left ({\mathrm e}^{2 i \left (f x +e \right )}-1\right )}-\frac {2 i b}{f \left ({\mathrm e}^{2 i \left (f x +e \right )}-1\right )}\) \(46\)

[In]

int(cot(f*x+e)^2*(a+b*sec(f*x+e)^2),x,method=_RETURNVERBOSE)

[Out]

1/f*(a*(-cot(f*x+e)-f*x-e)-b*cot(f*x+e))

Fricas [A] (verification not implemented)

none

Time = 0.25 (sec) , antiderivative size = 34, normalized size of antiderivative = 1.79 \[ \int \cot ^2(e+f x) \left (a+b \sec ^2(e+f x)\right ) \, dx=-\frac {a f x \sin \left (f x + e\right ) + {\left (a + b\right )} \cos \left (f x + e\right )}{f \sin \left (f x + e\right )} \]

[In]

integrate(cot(f*x+e)^2*(a+b*sec(f*x+e)^2),x, algorithm="fricas")

[Out]

-(a*f*x*sin(f*x + e) + (a + b)*cos(f*x + e))/(f*sin(f*x + e))

Sympy [F]

\[ \int \cot ^2(e+f x) \left (a+b \sec ^2(e+f x)\right ) \, dx=\int \left (a + b \sec ^{2}{\left (e + f x \right )}\right ) \cot ^{2}{\left (e + f x \right )}\, dx \]

[In]

integrate(cot(f*x+e)**2*(a+b*sec(f*x+e)**2),x)

[Out]

Integral((a + b*sec(e + f*x)**2)*cot(e + f*x)**2, x)

Maxima [A] (verification not implemented)

none

Time = 0.27 (sec) , antiderivative size = 25, normalized size of antiderivative = 1.32 \[ \int \cot ^2(e+f x) \left (a+b \sec ^2(e+f x)\right ) \, dx=-\frac {{\left (f x + e\right )} a + \frac {a + b}{\tan \left (f x + e\right )}}{f} \]

[In]

integrate(cot(f*x+e)^2*(a+b*sec(f*x+e)^2),x, algorithm="maxima")

[Out]

-((f*x + e)*a + (a + b)/tan(f*x + e))/f

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 53 vs. \(2 (19) = 38\).

Time = 0.30 (sec) , antiderivative size = 53, normalized size of antiderivative = 2.79 \[ \int \cot ^2(e+f x) \left (a+b \sec ^2(e+f x)\right ) \, dx=-\frac {2 \, {\left (f x + e\right )} a - a \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) - b \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) + \frac {a + b}{\tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )}}{2 \, f} \]

[In]

integrate(cot(f*x+e)^2*(a+b*sec(f*x+e)^2),x, algorithm="giac")

[Out]

-1/2*(2*(f*x + e)*a - a*tan(1/2*f*x + 1/2*e) - b*tan(1/2*f*x + 1/2*e) + (a + b)/tan(1/2*f*x + 1/2*e))/f

Mupad [B] (verification not implemented)

Time = 19.28 (sec) , antiderivative size = 19, normalized size of antiderivative = 1.00 \[ \int \cot ^2(e+f x) \left (a+b \sec ^2(e+f x)\right ) \, dx=-a\,x-\frac {\mathrm {cot}\left (e+f\,x\right )\,\left (a+b\right )}{f} \]

[In]

int(cot(e + f*x)^2*(a + b/cos(e + f*x)^2),x)

[Out]

- a*x - (cot(e + f*x)*(a + b))/f